package com.qxsx.midi.activity.home;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.qxsx.midi.R;
import com.qxsx.midi.activity.base.BaseActivity;
import com.qxsx.midi.utils.CustomProgress;
import com.qxsx.midi.utils.MyNet;
import com.qxsx.midi.utils.callBackJsonArray;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by Joney on 2015/9/11.
 * <p/>
 * 证书查询
 */
public class CertificateSearchFinishActivity extends BaseActivity {
//    private CustomProgress customProgress;

    private TextView tv_name, tv_gender, tv_national, tv_nation, tv_id, tv_level, tv_data, tv_stoplevel, tv_number, tv_major;
    String search;
    String id, midi_id, real_name,
            sex,
            nationality,
            people,
            major_name,
            start_end_grade,
            grade_num,
            certificate_date,
            certificate_num;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_certificate_search_finish);
        setTitle("证书查询");
        setNavBtn(R.mipmap.back, 0);

        Intent intent = getIntent();
        //search = intent.getStringExtra("search");//得到ID
        id = intent.getStringExtra("id");//得到ID
        midi_id = intent.getStringExtra("midi_id");//得到ID
        real_name = intent.getStringExtra("real_name");//得到ID
        sex = intent.getStringExtra("sex");//得到ID
        nationality = intent.getStringExtra("nationality");//得到ID
        people = intent.getStringExtra("people");//得到ID
        major_name = intent.getStringExtra("major_name");//得到ID
        start_end_grade = intent.getStringExtra("start_end_grade");//得到ID
        grade_num = intent.getStringExtra("grade_num");//得到ID
        certificate_date = intent.getStringExtra("certificate_date");//得到ID
        certificate_num = intent.getStringExtra("certificate_num");//得到ID
        findById();
        //certificate();

        tv_name.setText(real_name);
        if (sex.toString().equals("1")) {
            tv_gender.setText("男");
        } else {
            tv_gender.setText("女");
        }

        tv_national.setText(nationality);
        tv_nation.setText(people);
        tv_id.setText(midi_id);
        tv_major.setText(major_name);
        tv_level.setText(grade_num);
        tv_data.setText(certificate_date);
        tv_stoplevel.setText(start_end_grade);
        tv_number.setText(certificate_num);


    }

    private void findById() {
        tv_name = (TextView) findViewById(R.id.certificate_name);//姓名
        tv_gender = (TextView) findViewById(R.id.certificate_gender);//性别
        tv_national = (TextView) findViewById(R.id.certificate_national);//国籍
        tv_nation = (TextView) findViewById(R.id.certificate_nation);//民族
        tv_id = (TextView) findViewById(R.id.certificate_id);//ID
        tv_major = (TextView) findViewById(R.id.certificate_major);//考级专业
        tv_level = (TextView) findViewById(R.id.certificate_level);//等级
        tv_data = (TextView) findViewById(R.id.certificate_data);//发证日期
        tv_stoplevel = (TextView) findViewById(R.id.certificate_stoplevel);//起止级
        tv_number = (TextView) findViewById(R.id.certificate_number);//证书编号
    }

    @Override
    protected void HandleTitleBarEvent(TitleBar component, View v) {
        switch (component) {
            case LEFT:
                finish();
                break;

        }
    }

//    private void certificate() {
//        customProgress = CustomProgress.show(CertificateSearchFinishActivity.this, "正在查询，请稍后....", true, null);
//
//        JSONObject object = new JSONObject();
//        JSONArray array = new JSONArray();
//
//
//        try {
//            object.put("certificate_num", search);
//
//            array.put(object);
//        } catch (JSONException e) {
//            e.printStackTrace();
//        }
//
//        MyNet.doPostJsonArray("510", array, new callBackJsonArray() {
//            @Override
//            public void run(Object code, Object message, JSONArray array) {
//                Log.w("array", array + "");
//                if (array.length() == 0) {
//                    ShowToast("您输入的证书账号有误");
//                    customProgress.dismiss();
//                   return;
//                } else {
//                    try {
//                        JSONObject object1 = array.getJSONObject(0);
//                        String id = object1.getString("id");
//                        String midi_id = object1.getString("midi_id");
//                        String real_name = object1.getString("real_name");
//                        String sex = object1.getString("sex");
//                        String nationality = object1.getString("nationality");
//                        String people = object1.getString("people");
//                        String major_name = object1.getString("major_name");
//                        String start_end_grade = object1.getString("start_end_grade");
//                        String grade_num = object1.getString("grade_num");
//                        String certificate_date = object1.getString("certificate_date");
//                        String certificate_num = object1.getString("certificate_num");
//
//                        tv_name.setText(real_name);
//                        if (sex.toString().equals("1")) {
//                            tv_gender.setText("男");
//                        } else {
//                            tv_gender.setText("女");
//                        }
//
//                        tv_national.setText(nationality);
//                        tv_nation.setText(people);
//                        tv_id.setText(midi_id);
//                        tv_major.setText(major_name);
//                        tv_level.setText(grade_num);
//                        tv_data.setText(certificate_date);
//                        tv_stoplevel.setText(start_end_grade);
//                        tv_number.setText(certificate_num);
//
//
//                    } catch (JSONException e) {
//                        e.printStackTrace();
//                    }
//                }
//                customProgress.dismiss();
//            }
//        });
//
//
//    }

}
